package com.yc.sole.erp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yc.sole.erp.enums.OrderState;
import com.yc.sole.erp.enums.PaymentState;
import com.yc.sole.erp.enums.PriorityType;
import com.yc.sole.erp.enums.ShipmentState;
import com.yc.sole.framework.mybatis.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;

import java.math.BigDecimal;

/**
 * 销售订单表
 *
 * @author yizuomin
 * @date 2023/5/7 21:28
 **/
@Data
@Entity
@Table(name = "erp_sale_order", indexes = {
        @Index(name = "idx_order_no", columnList = "orderNo", unique = true)
})
@TableName(value = "erp_sale_order", autoResultMap = true)
public class SaleOrder extends BaseEntity {

    /**
     * 主键
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.AUTO)
    private Long id;
    /**
     * 订单编号
     */
    @Column(columnDefinition = "VARCHAR(32) NOT NULL COMMENT '订单编号'", unique = true)
    private String orderNo;
    /**
     * 订单日期
     */
    @Column(columnDefinition = "VARCHAR(20) NOT NULL COMMENT '订单日期'")
    private String orderDate;
    /**
     * 客户id
     */
    @Column(columnDefinition = "BIGINT NOT NULL COMMENT '客户id'")
    private Long customerId;
    /**
     * 客户名称
     */
    @Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '客户名称'")
    private String customerName;
    /**
     * 产品id
     */
    @Column(columnDefinition = "BIGINT NOT NULL COMMENT '产品id'")
    private Long productId;
    /**
     * 产品名称
     */
    @Column(columnDefinition = "VARCHAR(50) NOT NULL COMMENT '产品id'")
    private String productName;
    /**
     * 含税单价
     */
    @Column(columnDefinition = "DECIMAL(18,2) UNSIGNED NOT NULL COMMENT '含税单价'")
    private BigDecimal unitPrice;
    /**
     * 数量
     */
    @Column(columnDefinition = "INT UNSIGNED NOT NULL COMMENT '数量'")
    private Integer quantity;
    /**
     * 单位
     */
    @Column(columnDefinition = "VARCHAR(10) NOT NULL COMMENT '单位'")
    private String unit;
    /**
     * 总价
     */
    @Column(columnDefinition = "DECIMAL(18,2) UNSIGNED NOT NULL COMMENT '总价'")
    private BigDecimal amount;
    /**
     * 备注
     */
    @Column(columnDefinition = "VARCHAR(255) COMMENT '备注'")
    private String remark;
    /**
     * 优先级 0普通 1加急
     */
    @Column(columnDefinition = "TINYINT NOT NULL COMMENT '优先级'")
    private PriorityType priority;
    /**
     * 订单状态 0未处理 1处理中 2已完成 3已取消
     */
    @Column(columnDefinition = "TINYINT NOT NULL COMMENT '订单状态'")
    private OrderState orderState;
    /**
     * 付款状态 0待付款 1部分付款 2已付款
     */
    @Column(columnDefinition = "TINYINT NOT NULL COMMENT '付款状态'")
    private PaymentState paymentState;
    /**
     * 已付款金额
     */
    @Column(columnDefinition = "DECIMAL(18,2) UNSIGNED NOT NULL COMMENT '已付款金额'")
    private BigDecimal paidAmount;
    /**
     * 送货数量
     */
    @Column(columnDefinition = "INT UNSIGNED NOT NULL COMMENT '送货数量'")
    private Integer shippedQuantity;
    /**
     * 送货状态 0未送货 1部分送货 2已送货 3已签收
     */
    @Column(columnDefinition = "TINYINT NOT NULL COMMENT '送货状态'")
    private ShipmentState shipmentState;
    /**
     * 是否删除
     */
    @TableLogic
    @Column(columnDefinition = "INT NOT NULL DEFAULT 0 COMMENT '是否已删除'")
    private Integer deleted;
}
